package com.sws.web.controller.ry_rongyue.rel;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.enums.BusinessType;
import com.sws.rel.domain.PersonDeviceRel;
import com.sws.rel.service.IPersonDeviceRelService;
import com.sws.common.utils.poi.ExcelUtil;
import com.sws.common.core.page.TableDataInfo;

/**
 * 人员-设备关联管理Controller
 * 
 * @author cx
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/ry/pr_dv_rel/pr_dv_rel")
public class PersonDeviceRelController extends BaseController
{
    @Autowired
    private IPersonDeviceRelService personDeviceRelService;

    /**
     * 查询人员-设备关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonDeviceRel personDeviceRel)
    {
        startPage();
        List<PersonDeviceRel> list = personDeviceRelService.selectPersonDeviceRelList(personDeviceRel);
        return getDataTable(list);
    }

    /**
     * 导出人员-设备关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:export')")
    @Log(title = "人员-设备关联管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonDeviceRel personDeviceRel)
    {
        List<PersonDeviceRel> list = personDeviceRelService.selectPersonDeviceRelList(personDeviceRel);
        ExcelUtil<PersonDeviceRel> util = new ExcelUtil<PersonDeviceRel>(PersonDeviceRel.class);
        util.exportExcel(response, list, "人员-设备关联管理数据");
    }

    /**
     * 获取人员-设备关联管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(personDeviceRelService.selectPersonDeviceRelById(id));
    }

    /**
     * 新增人员-设备关联管理
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:add')")
    @Log(title = "人员-设备关联管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonDeviceRel personDeviceRel)
    {
        return toAjax(personDeviceRelService.insertPersonDeviceRel(personDeviceRel));
    }

    /**
     * 修改人员-设备关联管理
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:edit')")
    @Log(title = "人员-设备关联管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonDeviceRel personDeviceRel)
    {
        return toAjax(personDeviceRelService.updatePersonDeviceRel(personDeviceRel));
    }

    /**
     * 删除人员-设备关联管理
     */
    @PreAuthorize("@ss.hasPermi('ry/pr_dv_rel:pr_dv_rel:remove')")
    @Log(title = "人员-设备关联管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personDeviceRelService.deletePersonDeviceRelByIds(ids));
    }
}
